import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm';

@Entity('user_upload')
export class UserUploadEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ nullable: false, comment: '用户id' })
  userId: number;

  @Column({ nullable: false, comment: '用户ip地址' })
  userIp: string;

  @Column({ nullable: false, comment: '上传文件成功的链接' })
  uploadUrl: string;

  @Column({
    nullable: false,
    type: 'enum',
    enum: ['image', 'video'],
    default: 'image',
    comment: '上传文件类型，只能是image或video',
  })
  type: 'image' | 'video';

  @Column({
    nullable: false,
    default: () => 'CURRENT_TIMESTAMP',
    comment: '创建时间',
  })
  createTime: Date;
}
